/*
 * Copyright (C) 2017 Hisilicon Limited.
 *
 * This program is free software; you can redistribute it and /or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version
 */

#ifndef _DEVDRV_SYSFS_H_
#define _DEVDRV_SYSFS_H_

#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/types.h>
#include <linux/workqueue.h>

#include "devdrv_device_load.h"
#include "nvme_drv.h"
#include "apb_drv.h"
#include "devdrv_atu.h"

#define DEVDRV_SYSFS_RX_LANE_MAX 4
#define DEVDRV_SYSFS_TX_LANE_MAX 4

#define DEVDRV_SYSFS_MSG_IN_BYTES 4
#define DEVDRV_SYSFS_MSG_OUT_DATA_LEN 128


enum devdrv_sysfs_msg_type {
    DEVDRV_SYSFS_RX_PARA = 0,
    DEVDRV_SYSFS_TX_PARA,
    DEVDRV_SYSFS_LINK_INFO,
    DEVDRV_SYSFS_AER_COUNT,
    DEVDRV_SYSFS_AER_CLEAR,
    DEVDRV_SYSFS_HDC_COMMON_MSG_INFO,
    DEVDRV_SYSFS_MSG_TYPE_MAX
};

struct devdrv_sysfs_link_info {
    enum devdrv_sysfs_msg_type type;
    u32 link_speed;
    u32 link_width;
    u32 link_status;
};

struct devdrv_sysfs_rx_lane_para {
    u32 att;
    u32 gain;
    u32 boost;
    u32 tap1;
    u32 tap2;
    u32 valid;
};

struct devdrv_sysfs_rx_para {
    u32 lane_count;
    struct devdrv_sysfs_rx_lane_para lane_rx_para[DEVDRV_SYSFS_RX_LANE_MAX];
};


struct devdrv_sysfs_tx_lane_para {
    u32 pre;
    u32 main;
    u32 post;
    u32 valid;
};

struct devdrv_sysfs_tx_para {
    u32 lane_count;
    struct devdrv_sysfs_tx_lane_para lane_tx_para[DEVDRV_SYSFS_TX_LANE_MAX];
};


struct devdrv_sysfs_msg {
    enum devdrv_sysfs_msg_type type;
    union {
        u32 data[DEVDRV_SYSFS_MSG_OUT_DATA_LEN];
        struct devdrv_sysfs_link_info link_info;
        struct devdrv_sysfs_rx_para rx_para;
        struct devdrv_sysfs_tx_para tx_para;
    };
};

#endif
